﻿/* ***** BEGIN LICENSE BLOCK *****
 * Version: MPL 1.1
 *
 * The contents of this file are subject to the Mozilla Public License
 * Version 1.1 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific language governing rights and limitations
 * under the License.
 *
 * The Original Code is tyzoh.jp code.
 *
 * The Initial Developer of the Original Code is Kazutaka Kurihara.
 * Portions created by the Initial Developer are Copyright (C) 2007
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s):
 *
 * ***** END LICENSE BLOCK ***** */
using System;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.Data;
using Microsoft.Ink;
using System.Reflection;
using System.IO;
using ToolBarDock;

namespace Qurihara
{
    public class Kotodama_ : Qurihara.IKotodamaBase
    {
        //protected bool lockWindow = false;
        //public System.Windows.Forms.Form form;
        protected System.Windows.Forms.Control form;
        protected Qurihara.Presentation presen;
        protected Microsoft.Ink.InkCollector inkCollector;
        protected Qurihara.FigureElementList selectedElementList;
        //protected ToolBarManager toolBarManager;
        protected Qurihara.QBasic.FocusManager focusManager;
        protected System.Collections.Hashtable environmentTable;
        //public Kotodama_(System.Windows.Forms.Form f,Qurihara.Presentation p,Microsoft.Ink.InkCollector ic,Qurihara.FigureElementList sel,ToolBarManager tbm,Qurihara.QBasic.FocusManager fm,System.Collections.Hashtable tbl)
        //public Kotodama_(System.Windows.Forms.Form f,Qurihara.Presentation p,Microsoft.Ink.InkCollector ic,Qurihara.FigureElementList sel,ToolBarManager tbm,Qurihara.QBasic.FocusManager fm,System.Collections.Hashtable tbl)
        public Kotodama_(System.Windows.Forms.Control canvas, System.Windows.Forms.Form f, Qurihara.Presentation p, Microsoft.Ink.InkCollector ic, Qurihara.FigureElementList sel, Qurihara.QBasic.FocusManager fm, System.Collections.Hashtable tbl)
        {
            form = canvas;// f;
            presen = p;
            inkCollector = ic;
            selectedElementList = sel;
            //toolBarManager = tbm;
            focusManager = fm;
            environmentTable = tbl;
            environmentTable.Add("Base.Form", f);
            //暫定処置。Kotopadに移行したら、ここはContextMenu.MenuItemsになる。
            environmentTable.Add("Base.MenuItems", f.Menu.MenuItems);

        }

        #region IKotodamaBase interfaces
        //			public System.Windows.Forms.Form Form
        //			{
        //				get{return form;}
        //				set{form = value;}
        //			}
        public System.Windows.Forms.Control Control
        {
            get { return form; }
            //set{form = value;}
        }
        /*
        public bool LockWindow
        {
            get{return lockWindow;}
            set{lockWindow = value;}
        }
        */
        public Qurihara.Presentation Presentation
        {
            get { return presen; }
            set { presen = value; }
        }
        public Microsoft.Ink.InkCollector InkCollector
        {
            get { return inkCollector; }
            set { inkCollector = value; }
        }
        public Qurihara.FigureElementList SelectedElementList
        {
            get { return selectedElementList; }
            set { selectedElementList = value; }
        }
        //public ToolBarManager ToolBarManager
        //{
        //    get { return toolBarManager; }
        //    set { toolBarManager = value; }
        //}
        public Qurihara.QBasic.FocusManager FocusManager
        {
            get { return focusManager; }
            set { focusManager = value; }
        }
        public System.Collections.Hashtable EnvironmentTable
        {
            get { return environmentTable; }
            set { environmentTable = value; }
        }
        public event Qurihara.DragDrop.FilesDropEventHandler FormFilesDropEventHandler;
        public event Qurihara.Keyboard.KeyboardDownEventHandler KeyboardDownEventHandler;
        public event Qurihara.Keyboard.KeyboardUpEventHandler KeyboardUpEventHandler;
        #endregion

        public void FireFormFilesDrop(Point p, Array a, string d)
        {
            if (FormFilesDropEventHandler != null)
            {
                FormFilesDropEventHandler(this, new Qurihara.DragDrop.FileDropEventArgs(p, a, d));
            }
        }

        public void FireKeyboardDown(System.Windows.Forms.Keys k)
        {
            if (KeyboardDownEventHandler != null)
            {
                KeyboardDownEventHandler(this, new System.Windows.Forms.KeyEventArgs(k));
            }
        }
        public void FireKeyboardUp(System.Windows.Forms.Keys k)
        {
            if (KeyboardUpEventHandler != null)
            {
                KeyboardUpEventHandler(this, new System.Windows.Forms.KeyEventArgs(k));
            }
        }
    }

	/// <summary>
	/// KotodamaMain の概要の説明です。
	/// </summary>
	public class KotodamaMain
	{
		public Qurihara.KotodamaForm form; // 親フォーム
//
//		private const float HitTestRadius = 30;
//		// Declare constant for the index of the x and y packet values
//		private const int XPacketIndex = 0;
//		private const int YPacketIndex = 1;

//		public static Size minSize = new Size(40,40); // 図形要素を縮小したとき、つぶれないための限界サイズ

		public InkCollector	myInkCollector;

		//画像関連
		Region regionToInvalidate;

		internal FigureElementList selectedElementList,subElementList
			,subElementList2,tmpElementList
			,copyElementList,copyAllElementList
			,workElementList
			,recogWorkElementList = null;
		//FigureElement tmpElement = null;
		Point CheckPoint;

//		//設定ファイル読み込みクラス
//		private QConfig conf;
		private string workingdir;
		private string DefaultProjectDirectory;

		//プレゼンテーションクラス
		public Presentation presen;
		//スライドクラス
		private Slide slide;
	
		private bool showingDefaultPresen;

//		//カスタマイズ系
//		private Font textFont = null;
//		private Color textColor;
//		private Color rectangleFillColor;
//		private Color rectangleOutLineColor;
//		private int outLineWidth;
//		//private int rectangleOutLineWidth;
//		private Color ellipseFillColor;
//		private Color ellipseOutLineColor;
//		//private int ellipseOutLineWidth;
//		private Color lineColor;
//		private Color arrowColor;
//
//		//印刷系
//		private IEnumerator pageToPrint;
//		private int slidesX = 1,slidesY = 1;
//		private int pageCount = 0;

		//dragdropManager
		private DragDropManager.DragDropManager m_DragDropManager;

		public KotodamaMain(Qurihara.KotodamaForm f)
		{
			form = f;

            f.panelCanvas.Dock = DockStyle.Fill;

			regionToInvalidate = new Region();
			subElementList = new FigureElementList();
			selectedElementList = new FigureElementList();
			tmpElementList = new FigureElementList();
			subElementList2 = new FigureElementList();
			copyElementList = new FigureElementList();
			copyAllElementList = new FigureElementList();
			workElementList = new FigureElementList();

			CheckPoint = new Point();		

			// InkCollectorインスタンス作成
			myInkCollector = new InkCollector(form.panelCanvas);//.Handle);
			StrokeElement.Init(myInkCollector,form.panelCanvas);

			// 画面サイズ設定
			form.Resize += new EventHandler(Form_Resize);
			ratio = (float)form.ClientSize.Width/ (float)form.ClientSize.Height;


			myInkCollector.DefaultDrawingAttributes.PenTip = PenTip.Ball;
			myInkCollector.DefaultDrawingAttributes.Width = 75;//125;
			myInkCollector.DefaultDrawingAttributes.Color = Color.Red;
			myInkCollector.DefaultDrawingAttributes.Transparency = 1;
			//myInkCollector.DefaultDrawingAttributes.IgnorePressure = form.menuItemPenPressureEnabled.Checked;
			myInkCollector.DefaultDrawingAttributes.IgnorePressure = false;

			/*
			textColor = Color.Black;
			textFont = new Font("Times",16);
			//textFont = new Font("Arial",16);
			//rectangleColor = Color.FromArgb(127,Color.Violet);
			//ellipseColor = Color.FromArgb(127,Color.Aqua);
			rectangleFillColor = Color.Violet;
			rectangleOutLineColor = Color.Black;
			//rectangleOutLineWidth = 1;
			outLineWidth = 1;
			ellipseFillColor = Color.Aqua;
			ellipseOutLineColor = Color.Black;
			//ellipseOutLineWidth = 1;
			lineColor = Color.Black;
			lineDashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
			arrowColor = Color.Black;
			arrowDashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
			*/
		}

// 親フォームのシステム系イベントハンドラの処理
		public void Load(object sender, System.EventArgs e)
		{

			//showingDefaultPresen = true;
			showingDefaultPresen = false;

			bool close = false;
			
			if (!close)
			{
				presen = new Presentation(form.panelCanvas.ClientSize,form.panelCanvas);// form.ClientSize,form);//,System.IO.Directory.GetCurrentDirectory() + @"\resorces\background1.jpg");
				slide = presen.CurrentSlide;

				workingdir = System.IO.Path.GetDirectoryName(GetType().Assembly.Location);//System.IO.Directory.GetCurrentDirectory();
				//conf = new QConfig(workingdir);
				//conf.DefaultProjectDirectory = workingdir + @"\KOTODAMA_project";
				DefaultProjectDirectory = workingdir + @"\KOTODAMA_project";

				//form.openFileDialog.InitialDirectory = conf.DefaultProjectDirectory;
				form.openFileDialog.InitialDirectory = DefaultProjectDirectory;
                form.saveFileDialog.InitialDirectory = DefaultProjectDirectory;
				
				// MRU menu init
				// Initialize MRU manager
                form.mruManager = new MRUManager.FileMRUManager();

                // 完全なディレクトリと exe 名
                string fullAppName = Assembly.GetExecutingAssembly().GetName().CodeBase;
                string localPath = fullAppName.Substring(((string)("file:///")).Length);
                // exe 名除外
                string fullAppPath = Path.GetDirectoryName(localPath);
                // パスにファイル名が追加
                string registryPath = Path.Combine(fullAppPath, "mru.txt");

                //form.mruManager.Initialize(form, form.MRUMenuItem, registryPath);

				// Initialize DragDropManager
				m_DragDropManager = new DragDropManager.DragDropManager(form);

                slide.SlideSizeInvalidated += new EventHandler(slide_SlideSizeInvalidated);
                StartDefaultPresen(true);
            }

		}

        void slide_SlideSizeInvalidated(object sender, EventArgs e)
        {
            UpdatePanelCanvas(slide.SlideSize);
        }
        private void UpdatePanelCanvas(Size slideSize)
        {
            form.panelCanvas.Dock = DockStyle.None;
            //float aspect = (float)form.ClientSize.Width / (float)form.ClientSize.Height;
            Rectangle newPanelRect = QBasic.DrawingUtil.GetBoxedRectangleWithAspectRatioPreserved(slideSize, form.ClientRectangle);
            form.panelCanvas.Location = new Point(newPanelRect.X, newPanelRect.Y);
            form.panelCanvas.Size = new Size(newPanelRect.Width, newPanelRect.Height);
            slide.View.ScreenSize = form.panelCanvas.Size;
            form.panelCanvas.Invalidate();
        }

		private void StartDefaultPresen(bool coerce)
		{
            //デフォルトプレゼンの読み込み
            FormMenuStartNewPresen_Click(this, new EventArgs(),coerce);

            ////string path = conf.DefaultProjectDirectory + "\\スタートページ\\スタートページ.kp.xml";
            ////if (!System.IO.File.Exists(path)) conf.CopySystemFilesToProjectDir();
            //bool flag = form.mruManager.OpenDefault();
            //if (flag == false)
            //{
            //    string path = workingdir + @"\KOTODAMA_project\FirstPage\FirstPage.kp.xml";
            //    presen.LoadStartPresen(path);
            //}
		}
		//public void Paint(object sender, System.Windows.Forms.PaintEventArgs e,bool showNoEdittingElement)
		public void Paint(Graphics g,bool showNoEdittingElement)
		{
			presen.draw(g,showNoEdittingElement);

			//g.Dispose();   これがあるとリリースビルドは動かない。
		}
		public void Closing(object sender,System.ComponentModel.CancelEventArgs e)
		{
			if (this.Closing() == false)
			{
				e.Cancel = true;
			}
		}

		private float ratio;
		public void Form_Resize(object sender, System.EventArgs e)
		{
			if (slide != null)
			{
                //Size windowSize;
                //windowSize = new Size((int)(form.ClientSize.Height*ratio),form.ClientSize.Height);

				//縦横比をいつでも固定。機種比依存
				//float ratio = 1024f/768f;
				//slide.View.ScreenSize = new Size((int)(windowSize.Height*ratio),windowSize.Height);
				
				//最初の最大化画面で固定。機種依存。
                //slide.View.ScreenSize = new Size(windowSize.Width,windowSize.Height);

                //内部表示パネルをリサイズ
                UpdatePanelCanvas(slide.SlideSize);

				form.Invalidate();
			}
		}

		#region toolbar関係
		public void FormMenuToolBarsPopUp(object sender , System.EventArgs e)
		{
			form.menuItemToolBars.MenuItems.Clear();
			foreach (Control c in form.toolBarManager.GetControls())
			{
				ToolBarDock.ToolBarDockHolder holder = form.toolBarManager.GetHolder(c);
				MenuItem mi = new MenuItem(holder.ToolbarTitle, new EventHandler(this.viewToolbarsClicked));
				mi.Checked = holder.Visible;
				form.menuItemToolBars.MenuItems.Add(mi);
			}

		}
		private void viewToolbarsClicked(object sender, EventArgs e)
		{
			MenuItem mi = sender as MenuItem;
			ToolBarDock.ToolBarDockHolder holder = form.toolBarManager.GetHolder(mi.Text);
			form.toolBarManager.ShowControl(holder.Control, !holder.Control.Visible);
		}
		#endregion

// コントロール系イベントハンドラ

        //返値がtrueなら、先にすすんでよい。falseならキャンセル。
        public bool SaveIfUnsaved()
        {
            if (presen.CurrentSlide.Dirty)
            {
                DialogResult dr = MessageBox.Show("現在開いているファイルはまだ保存していません。保存しますか？", "", MessageBoxButtons.YesNoCancel);
                if (dr == DialogResult.Yes)
                {
                    if (FormMenuSavePresen_Click(this, new EventArgs()))
                    {
                        return true;
                    }
                    return false;
                }
                if (dr == DialogResult.No) return true;
                return false;
            }
            return true;
        }
		public bool FormMenuSavePresen_Click(object sender, System.EventArgs e)
		{
            form.saveFileDialog.Filter = "ことだまファイル(*.ks.xml)|*.*";
            form.saveFileDialog.DefaultExt = ".ks.xml";
            form.saveFileDialog.AddExtension = true;
            //saveFileDialog.InitialDirectory
            form.saveFileDialog.SupportMultiDottedExtensions = true;
            form.saveFileDialog.FileName = QBasic.Util.getTimeNowString() + ".ks.xml";

            if (form.saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                string savefile = form.saveFileDialog.FileName;
                slide.SaveAsXml(savefile, false);
                return true;
            }
            return false;
		}
        public bool FormMenuSaveSimpleXML()
        {
            form.saveFileDialog.Filter = "ことだまファイル(*.ks.xml)|*.*";
            form.saveFileDialog.DefaultExt = ".ks.xml";
            form.saveFileDialog.AddExtension = true;
            form.saveFileDialog.SupportMultiDottedExtensions = true;
            form.saveFileDialog.FileName = QBasic.Util.getTimeNowString() + ".ks.xml";

            if (form.saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                string savefile = form.saveFileDialog.FileName;
                slide.SaveAsSimpleXml(savefile, false);
                return true;
            }
            return false;
        }
	
		public void FormMenuReDo_Click(object sender, System.EventArgs e)
		{
			if (slide.Do())
			{
				selectedElementList.Highlight = false;
				selectedElementList.Clear();
				updateAll();
			}
			else
			{
                if (QBasic.Util.IsPropertyTrue("Base.English"))
                {
                    MessageBox.Show("No more Redo histories.");
                }
                else
                {
                    MessageBox.Show("ReDoできる履歴はありません。");
                }

			}
		}

		public void FormMenuUnDo_Click(object sender, System.EventArgs e)
		{
			
			if (slide.UnDo())
			{
				selectedElementList.Highlight = false;
				selectedElementList.Clear();
				updateAll();
			}
			else
			{
                if (QBasic.Util.IsPropertyTrue("Base.English"))
                {
                    MessageBox.Show("No more Undo histories.");
                }
                else
                {
                    MessageBox.Show("UnDoできる履歴はありません。");
                }

			}
		}
		public void LoadStartPresen(string file)
		{
            try
            {
                Stream stream = File.OpenRead(file);
                slide.Load(stream,Path.GetDirectoryName(file));
                stream.Close();

                updateAll();
                showingDefaultPresen = false;
                form.mruManager.Add(file);

                DialogResult dr = MessageBox.Show("現在のウインドウサイズに資料の縦横比をあわせますか？「いいえ」を選ぶと資料本来の比率のまま開きます。", "資料の縦横比の調整", MessageBoxButtons.YesNo);
                if (dr == DialogResult.Yes)
                {
                    //現在のwindowsize
                    form.panelCanvas.Dock = DockStyle.Fill;
                    //form.Refresh();
                    //slide.View.ScreenSize = form.panelCanvas.Size;
                    //form.panelCanvas.Invalidate();
                    Size ts = form.panelCanvas.Size;
                    slide.SlideSize = ts;
                    //UpdatePanelCanvas(ts);
                }
            }
            catch (Exception ex)
            {
                // remove file from MRU list
                form.mruManager.Remove(file);

                MessageBox.Show(
                    form,
                    ex.Message,
                    "Error loading from file");
            }
		}
		public void FormMenuLoadStartPresen_Click(object sender, System.EventArgs e)
		{
            form.openFileDialog.Filter = "ことだまファイル(*.ks.xml)|*.*";
            if (form.openFileDialog.ShowDialog() == DialogResult.OK)
            {
                LoadStartPresen(form.openFileDialog.FileName);
            }
            form.openFileDialog.Filter = null;
		}
		public void FormMenuStartNewPresen_Click(object sender, System.EventArgs e, bool coerce)
		{
            Assembly assm = Assembly.GetExecutingAssembly();
            Stream stream = assm.GetManifestResourceStream("KotodamaForm.init.ks.xml");
            slide.Load(stream,"");
            stream.Close();
            //presen.CurrentSlideInvalidate();

            if (!coerce)
            {
                DialogResult dr = MessageBox.Show("現在のウインドウサイズで資料を作成しますか？ 「いいえ」を選ぶと標準の4:3になります", "", MessageBoxButtons.YesNo);
                if (dr == DialogResult.Yes)
                {
                    //現在のwindowsize
                    form.panelCanvas.Dock = DockStyle.Fill;
                    //form.Refresh();
                    //slide.View.ScreenSize = form.panelCanvas.Size;
                    //form.panelCanvas.Invalidate();
                    Size ts = form.panelCanvas.Size;
                    slide.SlideSize = ts;
                    //UpdatePanelCanvas(ts);
                }
                if (dr == DialogResult.No)
                {
                    //4:3で作成
                    Size ts = new Size(4, 3);
                    Rectangle newPanelRect = QBasic.DrawingUtil.GetBoxedRectangleWithAspectRatioPreserved(ts, form.ClientRectangle);
                    slide.SlideSize = newPanelRect.Size;
                    //UpdatePanelCanvas(newPanelRect.Size);
                }
                //if (form.WindowState != FormWindowState.Maximized)
                //{
                //}
            }
		}

		public void FormMenuCopyAndPaste_Click(object sender, System.EventArgs e)
		{// ちょっとずれたところに複写する。
			/*
			if(selectedElementList.Count >0)
			{
				selectedElementList.Highlight = false;
				//selectedElementListは変化します。
				slide.CopyAndPasteObjects(ref selectedElementList,ref tmpElementList,50,50);
				//selectedElementList.Clear();
				//selectedElementList.AddNewElement(tmpElementList);
				selectedElementList.Highlight = true;
				
				selectedElementList.AddToInvalidateRegion(ref regionToInvalidate
					,slide.ElementList
					,workElementList);

				this.update();
				//form.Refresh();
			}
		*/
		}
		public void FormMenuFormBySize_Click(object sender, System.EventArgs e)
		{
			/*
			
			if (currentmode == MODE.SELECT && selectedElementList.Count > 1)
			{
				selectedElementList.AddToInvalidateRegion(ref regionToInvalidate,
					slide.ElementList,
					workElementList);
				_formBySize(selectedElementList);
				selectedElementList.AddToInvalidateRegion(ref regionToInvalidate,
					slide.ElementList,
					workElementList);
				update();
			}
		*/
		}

		public void FormMenuUnifyVerticalAxis_Click(object sender, System.EventArgs e)
		{ // 縦軸あわせ			
			/*
			if (currentmode == MODE.SELECT && selectedElementList.Count > 1)
			{
				slide.UnifyAxis(selectedElementList,true);
				selectedElementList.AddToInvalidateRegion(ref regionToInvalidate,
					slide.ElementList,
					workElementList);
			}
			this.update();
			*/
		}
		public void FormMenuUnifyHorizontalAxis_Click(object sender, System.EventArgs e)
		{ // 横軸あわせ
/*
			if (currentmode == MODE.SELECT && selectedElementList.Count > 1)
			{
				slide.UnifyAxis(selectedElementList,false);
				selectedElementList.AddToInvalidateRegion(ref regionToInvalidate,
					slide.ElementList,
					workElementList);
			}
			this.update();
*/
		}
		public void FormMenuAlignmentVerticalAxis_Click(object sender, System.EventArgs e)
		{ // 縦等間隔配置
/*
			if (currentmode == MODE.SELECT && selectedElementList.Count > 1)
			{
				slide.AlignAxis(selectedElementList,true);
				selectedElementList.AddToInvalidateRegion(ref regionToInvalidate,
					slide.ElementList,
					workElementList);
			}
			this.update();
*/
		}
		public void FormMenuAlignmentHorizontalAxis_Click(object sender, System.EventArgs e)
		{ // 横等間隔配置
/*
			if (currentmode == MODE.SELECT && selectedElementList.Count > 1)
			{
				slide.AlignAxis(selectedElementList,false);
				selectedElementList.AddToInvalidateRegion(ref regionToInvalidate,
					slide.ElementList,
					workElementList);
			}
			this.update();
*/
		}

		public void FormMenuMakeGroup_Click(object sender, System.EventArgs e)
		{// グループ化
//
//			if (currentmode == MODE.SELECT && selectedElementList.Count > 1)
//			{
//				selectedElementList.Highlight = false;
//				slide.createElementGroup(ref selectedElementList);
//				selectedElementList.Clear();
//				//本当ならグループエレメントを選択したい。
//				this.update();
//				//form.Refresh();
//			}
		}
		public void FormMenuReleaseGroup_Click(object sender, System.EventArgs e)
		{// グループ化解除
//			if (currentmode == MODE.SELECT && selectedElementList.Count > 0)
//			{
//				// セレクトされているすべてのgroupElementをリリースする。
//				selectedElementList.Highlight = false;
//				slide.ReleaseElementGroup(ref selectedElementList);
//				selectedElementList.Clear();
//				//本当なら解除したエレメントを選択したい。
//				this.update();
//				//form.Refresh();
//			}
		}

		public void FormMenuReDraw_Click(object sender, System.EventArgs e)
		{
			updateAll();
		}
		public void FormMenuDoubleBufferCheckButton_Click(object sender, System.EventArgs e)
		{
			form.DoubleBufferCheckButton.Checked = !form.DoubleBufferCheckButton.Checked;
			bool db = form.DoubleBufferCheckButton.Checked;
			form.SetDoubleBuffer(db);

		}

// ******************

// 内部呼び出し

		public void updateAll()
		{
			form.Invalidate();
			regionToInvalidate.MakeEmpty();
		}
//

		public void gestureEnable(bool e)
		{
			myInkCollector.SetGestureStatus(ApplicationGesture.Circle, e);
			myInkCollector.SetGestureStatus(ApplicationGesture.Square, e);
			myInkCollector.SetGestureStatus(ApplicationGesture.ChevronDown , e);
		}

		// イベントハンドラ付属系
		private void _formBySize(FigureElementList fel)
		{
			/*
			slide.FormBySize(fel);
			*/
		}

		private void _formByAlligment(FigureElementList fel,int dx,int dy)
		{
			/*
			int ix = form.ClientRectangle.Width / dx;
			int iy = form.ClientRectangle.Height / dy;
			int xx,yy;
			Rectangle r;
			IEnumerator enume;
			enume = fel.GetEnumerator();
			while (enume.MoveNext())
			{
				if (((FigureElement)enume.Current).GetType() != typeof(ArrowElement))
				{
					r = ((FigureElement)enume.Current).BoundingBox;
					xx = ((FigureElement)enume.Current).MidPoint.X / ix;
					yy = ((FigureElement)enume.Current).MidPoint.Y / iy;

					slide.MoveObject((FigureElement)enume.Current
						,xx*ix - (r.X +r.Width/2)
						,yy*iy - (r.Y +r.Height/2));
				}
			}
			this.update();
		*/
		}
		
		private bool Closing()
		{
            if (presen.CurrentSlide.Dirty)
            {
                DialogResult dr = MessageBox.Show("現在開いているファイルはまだ保存していません。保存しますか？", "", MessageBoxButtons.YesNoCancel);
                if (dr == DialogResult.Yes)
                {
                    if (FormMenuSavePresen_Click(this,new EventArgs()))
                        return true;
                    return false;
                }
                else if (dr == DialogResult.No)
                {
                    return true;
                }
                return false;
            }
            return true;

		}

	}
}
